<template>
  <div class="flex flex-col day-done-picking">
    <line-logo :name="$i18n.t('mesProductionDailyClear.givingUp')" />
    <div class="mt-24 flex align-center top-item justify-around">
      <div class="flex align-end content-center" v-for="(item, index) in topArr" :key="index">
        <div class="flex flex-col ml-12 align-center">
          <span class="color-5A6F82">{{ item.label }}</span>
          <strong class="font-20 color-333 mt-8">{{ item.value || 0 }}</strong>
        </div>
      </div>
    </div>
    <div class="flex align-center mt-18 content-between">
      <strong class="font-13">{{ $i18n.t('mesProductionDailyClear.closingDetails') }}</strong>
      <el-button type="primary" @click="handleExport" icon="el-icon-download">{{ $i18n.t('mesProductionDailyClear.export') }}</el-button>
    </div>
    <el-table class="mt-12" :max-height="350" :data="dataItem.pickMaterialInfoList">
      <el-table-column :label="$i18n.t('mesProductionDailyClear.order')" type="index" align="center" width="50" />
      <el-table-column :label="$i18n.t('mesProductionDailyClear.workshop')" prop="workShopName" align="center" show-tooltip-when-overflow />
      <el-table-column :label="$i18n.t('mesProductionDailyClear.materialName')" prop="prodName" align="center" show-tooltip-when-overflow />
      <el-table-column :label="$i18n.t('mesProductionDailyClear.materialCode')" prop="prodCode" align="center" show-tooltip-when-overflow />
      <el-table-column :label="$i18n.t('mesProductionDailyClear.needNumber')" prop="needNumber" align="center" />
      <el-table-column :label="$i18n.t('mesProductionDailyClear.list')" prop="receiveNumber" align="center" />
      <el-table-column :label="$i18n.t('mesProductionDailyClear.quantity')" prop="unReceiveNumber" align="center" />
    </el-table>
  </div>
</template>

<script>
import LineLogo from './line-logo.vue'
import { exportUrl } from '@/api/report/mesProductionDailyClear'
import { exportExcel } from '@/utils/judge'
export default {
  components: { LineLogo },
  props: {
    dataItem: {
      type: Object,
      default: () => {}
    },
    dataQuery: {
      type: Object,
      default: () => {}
    }
  },
  watch: {
    dataItem: {
      handler(val) {
        this.topArr[0].value = val.planMaterial || 0
        this.topArr[1].value = val.realMaterial || 0
        this.topArr[2].value = val.diffMaterial || 0
      },
      immediate: true,
      deep: true
    }
  },
  data() {
    return {
      topArr: [
        { label: $i18n.t('mesProductionDailyClear.materials'), value: 0, icon: 'icon_wlxq' },
        { label: $i18n.t('mesProductionDailyClear.actualPicking'), value: 0, icon: 'icon_sjll' },
        { label: $i18n.t('mesProductionDailyClear.difference'), value: 0, icon: 'icon_cy' }
      ],
      dataList: []
    }
  },
  methods: {
    handleExport() {
      this.$confirm($i18n.t('mesProductionDailyClear.confirmExportPicking'), $i18n.t('common.warning'), {
        confirmButtonText: $i18n.t('common.ok'),
        cancelButtonText: $i18n.t('common.cancel'),
        type: 'warning'
      }).then(() => {
        exportExcel(exportUrl, this.dataQuery)
      })
    }
  }
}
</script>
<style lang="scss">
.day-done-picking {
  .top-item {
    border-top: 4px solid #64b5ea;
    height: 125px;
    border-right: 1px solid #e5e5e5;
    border-left: 1px solid #e5e5e5;
    border-bottom: 1px solid #e5e5e5;
  }
}
</style>
